<?php 
/**
 * @version             $Id: install.db.php 
 * @package             Clickdesk
 * @license             http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL,
 */


?>
<?php
defined( '_JEXEC' ) or die( 'Restricted access' );
function com_install()
{
	if(!function_exists('curl_init'))
	{
		JError::raiseWarning( 100, 'WARNING: <br /><br />The component has been installed but requires cURL library to function properly. Please uninstall the iCopyright Article Tools component, install/enable the cURL and try installing the component again. <br />For further information, please send us an email at joomla@icopyright.net! <br /> ' );
	//return false;
}else{



		$db		=& JFactory::getDBO(); 

		$sql ='
CREATE TABLE IF NOT EXISTS #__clickdesk (
  id int(11) NOT NULL AUTO_INCREMENT,
  widget_id varchar(255) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

';
 


		$db->setQuery($sql );
		$db->query(); 

	
		jimport('joomla.installer.helper');
		$installer = new JInstaller();
		//$installer->_overwrite = true;

		$pkg_path = JPATH_ADMINISTRATOR.DS.'components'.DS.'com_clickdesk'.DS.'extensions'.DS;
		$pkgs = "plug_clickdesk.zip";
             
 
		$package = JInstallerHelper::unpack( $pkg_path.$pkgs );
 
		if( $installer->install( $package['dir'] ) )
		{
			$msgcolor = "#E0FFE0";
			$msgtext  = "clickdesk successfully installed.";
		}
		else
		{
			$msgcolor = "#FFD0D0";
			$msgtext  = "ERROR: Could not install the plugin for clickdesk. Please install manually.";
		}
?>
	<table bgcolor="<?php echo $msgcolor; ?>" width ="100%">
		<tr style="height:30px">
			<td width="50px"></td>
			<td><font size="2"><b><?php echo $msgtext; ?></b></font></td>
		</tr>
	</table>
<?php
JInstallerHelper::cleanupInstall( $pkg_path.$pkgs, $package['dir'] );
	
	
$component_url = JURI::root()."administrator/index.php?option=com_clickdesk";
?>
<dl id="system-message">
<dt class="message">Message</dt>
<dd class="message message fade">
<ul>
<li><span style="font-size:14px;color:#000000;#important!">Please <a href='<?php echo $component_url;?>'>click here</a> to clickdesk.</span></li>
</ul>
</dd>
</dl>
<?php
//return true;
}
}
?>